home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKitArchive.mbox / mbox / 000198_misckit-reques…aska.et.byu.edu_Sat May 28 21:33:46 1994.msg < prev    next >
Internet Message Format  |  1994-10-30  |  7KB

  1. Return-Path: <misckit-request@alaska.et.byu.edu>
  2. Received: from alaska.et.byu.edu by darth.byu.edu (NX5.67d/NX3.0M)
  3.     id AA09205; Sat, 28 May 94 21:33:34 -0600
  4. Received: from YVAX2.BYU.EDU by alaska.et.byu.edu; Sat, 28 May 1994 21:35:34 -0600
  5. Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.3-8 #4169)
  6.  id <01HCVYG7P440019CN9@yvax.byu.edu>; 28 May 94 21:34:38 -0600 (MDT)
  7. Received: from alaska.et.byu.edu by yvax.byu.edu (PMDF V4.3-8 #4169)
  8.  id <01HCVYG3BKTC0195EG@yvax.byu.edu>; Sat, 28 May 1994 21:34:32 -0600 (MDT)
  9. Received: from yvax1.byu.edu by alaska.et.byu.edu; Sat,
  10.  28 May 1994 21:30:24 -0600
  11. Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.3-8 #4169)
  12.  id <01HCVYA2M5DS9GV5LY@yvax.byu.edu>; Sat, 28 May 1994 21:29:41 MDT
  13. Received: from fsa.cpsc.ucalgary.ca by yvax.byu.edu (PMDF V4.3-8 #4169)
  14.  id <01HCVY9YY1K002LPOD@yvax.byu.edu>; Sat, 28 May 1994 21:29:37 -0600 (MDT)
  15. Received: from news.cpsc.ucalgary.ca (news.cpsc.ucalgary.ca [136.159.3.2])
  16.  by fsa.cpsc.ucalgary.ca (1.6) id <VAA02620@fsa.cpsc.ucalgary.ca>; Sat,
  17.  28 May 1994 21:28:50 -0600
  18. Received: by news.cpsc.ucalgary.ca (1.2; from uucp@localhost)
  19.  id <VAA02581@news.cpsc.ucalgary.ca>; Sat, 28 May 1994 21:29:43 -0600
  20. Received: from avocado.cuc.ab.ca by ajfcal.cuc.ab.ca (5.65c/Cuc2.2)
  21.  id AA06654; Sat, 28 May 1994 20:08:23 -0600
  22. Received: by avocado.cuc.ab.ca id AA03245
  23.  (5.65c#3#/IDA-1.4.4 for misckit@byu.edu); Sat, 28 May 1994 21:01:13 -0600
  24. Received: by NeXT.Mailer (1.100)
  25. Received: by NeXT Mailer (1.100)
  26. Date: Sat, 28 May 1994 21:01:13 -0600
  27. From: "R. Todd Thomas" <todd@avocado.cuc.ab.ca>
  28. Subject: Requesting input for file searching object design
  29. To: misckit@byu.edu
  30. Message-Id: <199405290301.AA03245@avocado.cuc.ab.ca>
  31. Content-Transfer-Encoding: 7BIT
  32.  
  33.  
  34.  
  35. Hello Everyone,
  36.  
  37.  
  38. Just looking for some input on the design of some classes for searching the filesystem. I have included the two interfaces that I've already come up with.
  39.  
  40. Here is what I have so far:        
  41. (FileSearch .h)
  42.  
  43. /***************************************************************************
  44.  * CLASS:        FileSearch
  45.  * INHERITS FROM:    Object
  46.  *
  47.  * Before creating this object, I tried to determine what kind of file
  48.  * searches one might want to do. Two came to mind: When you want to
  49.  * search for a specific file (find "image.tiff" in my ~/Icons directory)
  50.  * or searching for a list of files that meet some criteria (find me
  51.  * all files with the tiff extension).
  52.  *     
  53.  *    Searching for a specific file is done using the method
  54.  * -searchFor:inDirectory:recursive:followLinks: which will return the
  55.  * full pathname if the given filename is found.
  56.  *
  57.  *     Searching for filenames that meet some criteria is done with
  58.  * -searchDirectory:recursive:followLinks:. For each filename that is in
  59.  * the given directory, the delegate is asked if it should be added to
  60.  * list. Therefore, the delegate could filter filenames by extension,
  61.  * date, owner, or anything else you might think of. If there is no
  62.  * delegate set, then everything will be added to the list.
  63.  *
  64.  *************************************************************************/
  65. @interface FileSearch : Object
  66. {
  67.     id  delegate;
  68. }
  69.  
  70. + initialize;
  71. - init;
  72.  
  73. - setDelegate: theDelegate;
  74. - delegate;
  75.  
  76. // Methods for finding multiple filenames that match some criteria. The
  77. // delegate is used to determine what should be added to the list. A list
  78. // of MiscStrings is returned for all files that meet with the delegate's
  79. // approval.
  80.  
  81. - (List *)searchDirectory: (const char *)directory;
  82. - (List *)searchDirectory: (const char *)directory recursive:
  83.         (BOOL)recurse;
  84. - (List *)searchDirectory: (const char *)directory recursive:     
  85.         (BOOL)recurse
  86.         followLinks: (BOOL)followLinks;
  87.  
  88. // Methods for finding a single filename in a given directory. The
  89. // delegate is not used. If the filename is found within the given
  90. // directory, the full pathname is returned.
  91.  
  92. - (MiscString *)searchFor: (const char *)filename
  93.         inDirectory: (const char *)directory;
  94. - (MiscString *)searchFor: (const char *)filename
  95.         inDirectory: (const char *)directory recursive:     
  96.         (BOOL)recurse;
  97. - (MiscString *)searchFor: (const char *)filename
  98.         inDirectory: (const char *)directory recursive:
  99.         (BOOL)recurse
  100.         followLinks: (BOOL)followLinks;
  101.  
  102. // Delegate cover method
  103.  
  104. - (BOOL)_addFile: (const char *)filename
  105.         fromDirectory: (const char *)directory;        
  106.         
  107. // Archiving
  108.  
  109. - read: (NXTypedStream *)stream;
  110. - write: (NXTypedStream *)stream;
  111.     
  112. @end
  113.  
  114.  
  115.  
  116. @interface Object (FileSearchDelegate)
  117.  
  118. // Implemented by the delegate to determine which filenames make it onto
  119. // the list. Every file that is encountered in the directory stream is
  120. // sent to the delegate to see if it should be included in the returned
  121. // list of filenames. For instance, you could only include files with a
  122. // tiff extension.Return YES to be added to the list and NO if it
  123. // shouldn't.
  124.  
  125. - (BOOL)addFile: (const char *)filename fromDirectory: (const char *)directory;
  126.  
  127. @end
  128.  
  129.  
  130.  
  131. (DirectorySearch.h)
  132.  
  133. /*************************************************************************
  134.  * CLASS:        DirectorySearch
  135.  * INHERITS FROM:    FileSearch
  136.  *
  137.  *    This class extends the functionality of FileSearch by allowing you
  138.  * to keep a list of directories that should be searched. I thought this
  139.  * would be useful when doing things like finding all .mybundle in various
  140.  * directories (~/Library, /LocalLibrary, /Library, etc).
  141.  *
  142.  *************************************************************************/
  143. @interface DirectorySearch : FileSearch
  144. {
  145.     id  searchList;                // a list of the directory paths to search
  146. }
  147.  
  148. + initialize;
  149. - init;
  150. - free;
  151.  
  152. // Methods to manipulate and access the search list
  153.  
  154. - (BOOL)addPathToSearchList: (const char *)fullPath;
  155. - (BOOL)removePathFromSearchList: (const char *)fullPath;
  156. - (BOOL)pathExistsInList: (const char *)fullPath;
  157. - clearSearchList;
  158. - searchList;
  159.  
  160. // Methods for searching for multiple filenames.
  161. // The delegate still acts as the "filter" to return specific files.
  162.  
  163. - (List *)searchListForFiles;
  164. - (List *)searchListForFilesWithRecursion: (BOOL)recurse;
  165. - (List *)searchListForFilesWithRecursion: (BOOL)recurse
  166.         followLinks: (BOOL)followLinks;
  167.  
  168. // Methods for specific filename searches. It returns the fullpath if
  169. // found. The delegate is not used.
  170.  
  171. - (MiscString *)searchListForFilename: (const char *)filename;
  172. - (MiscString *)searchListForFilename: (const char *)filename
  173.         recursive: (BOOL)recurse;
  174. - (MiscString *)searchListForFilename: (const char *)filename
  175.         recursive: (BOOL)recurse followLinks: (BOOL)followLinks;
  176.  
  177. // Archiving methods
  178.         
  179. - read: (NXTypedStream *)stream;
  180. - write: (NXTypedStream *)stream;
  181.  
  182. @end
  183.  
  184.  
  185.  
  186. If anyone is interested in more information, or the information above is not clear enough, drop me a note.
  187.  
  188. Any alternate designs, criticisms, etc, are definitely welcome. Would anyone find classes like the above useful?
  189.  
  190.  
  191.  
  192. Oh, and for those that care, my next project is to fix up the MiscDragView, MiscImageView, and MiscIconWell classes.
  193.  
  194.  
  195. Todd Thomas
  196. todd@avocado.cuc.ab.ca        [NeXTMail]
  197.